export default {
    setup() {
        const formData = ref(new FormData());
        const pdfBlob = ref(null);

        const generateAndUpload = async () => {
            // 生成 PDF 文件流
            pdfBlob.value = await generatePdf('pdf-content');
            
            if (!pdfBlob.value) {
                console.error('Failed to generate PDF');
                return;
            }

            // 将 Blob 添加到 FormData
            formData.value.append('file', pdfBlob.value, 'document.pdf');

            // 预览 PDF
            const blobUrl = URL.createObjectURL(pdfBlob.value);
            window.open(blobUrl, '_blank');

            // 延迟释放资源
            setTimeout(() => URL.revokeObjectURL(blobUrl), 10000);
        };

    }
};